package com.itheima.controller;

import com.itheima.oss.AliOSSUtils;
import com.itheima.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class EmpController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result fileUpload(MultipartFile image) {
        try {
            String url = aliOSSUtils.upload(image);
            return Result.success(url);
        } catch (IOException e) {
            e.printStackTrace();
            return Result.error("出错啦"+e.getMessage());
        }

    }
}
